package validation;

import card.Cardset;

/**
 * Card Combination - Nuke
 * Valid:	BR
 * Invalid:	4444, 34567, 33344
 * 
 */
public class Nuke extends Type {

	private static Nuke instance;

	/**
	 *  Private Constructor
	 *  Set instance to null(default)
	 */
	private Nuke(){
		super();
		instance = null;
	}

	/**
	 * Implementation of Singleton
	 * @return Type instance
	 */
	public static Type getInstance(){
		if(instance == null){
			instance = new Nuke();
		}
		return instance;	
	}
	
	@Override
	public void clear(){
		instance = null;
	}
	
	@Override
	protected int getPriority(Cardset hand) {
		// TODO Auto-generated method stub
		
		/**
		 *  Remark:
		 *  No implementation needed as it can never be compared.
		 */
		return 0;
	}
	
	@Override
	public Type identify(Cardset thisHand) {
		// TODO Auto-generated method stub
		boolean isValid = false;
		int n = thisHand.count();
		if(n == 2){
			if(thisHand.getCard(0).getValue() == 'B' && thisHand.getCard(1).getValue() == 'R' )
				isValid = true;
			if(thisHand.getCard(0).getValue() == 'R' && thisHand.getCard(1).getValue() == 'B')
				isValid = true;
		}
		
		if(isValid)
			return getInstance();
		else
			return null;
	}

}
